home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from contacts.BuddyListElement import BuddyListElement
- from common.Buddy import fileinfo
- from util import strip_html, Storage
- import common
- import jabber
- from common.actions import action
- from common.Buddy import get_status_orb
- GTALK = 'gtalk'
- JABBER = 'jabber'
- statuses = Storage(dnd = _('Do Not Disturb'), chat = _('Free for Chat'), xa = _('Extended Away'))
-
- class JabberResource(BuddyListElement):
- __metaclass__ = common.ActionMeta
-
- def __init__(self, jabber, jid, presence):
- self.jid = jid
- self._set_presence(presence)
- self.name = self.jid.as_unicode()
- self.alias = self.name
- self.protocol = jabber
- self.sms = False
-
-
- def sort(self, *a, **k):
- pass
-
-
- def _set_presence(self, presence):
- self.status_msg = presence.get_status()
- self.show = presence.get_show()
- self.priority = presence.get_priority()
-
-
- def get_status_message(self):
- return self.status_msg
-
-
- def set_status_message(self, val):
- self.status_msg = val
-
- status_message = property(get_status_message, set_status_message)
-
- def stripped_msg(self):
- msg = self.status_message
- return None if msg else u''
-
- stripped_msg = property(stripped_msg)
-
- def service(self):
- if self.jid.domain == 'gmail.com':
- return GTALK
- else:
- return JABBER
-
- service = property(service)
-
- def away(self):
- if self.service == GTALK:
- if not (self.available):
- pass
- return not (self.idle)
- else:
- return not (self.available)
-
- away = property(away)
-
- def available(self):
- return self.show in jabber.available_show_types
-
- available = property(available)
-
- def idle(self):
- if self.service == GTALK:
- return self.show == 'away'
- else:
- return False
-
- idle = property(idle)
-
- def mobile(self):
- return False
-
- mobile = property(mobile)
-
- def icon(self):
- return False
-
- icon = property(icon)
-
- def pending_auth(self):
- return False
-
- pending_auth = property(pending_auth)
-
- def online(self):
- return True
-
- online = property(online)
-
- def blocked(self):
- return False
-
- blocked = property(blocked)
-
- def long_show(self):
- pass
-
- long_show = property(long_show)
- status_orb = property((lambda self: get_status_orb(self)))
-
- def sightly_status(self):
- status = self.show
- if status:
- return statuses.get(status, status.title())
- else:
- return _('Available')
-
- sightly_status = property(sightly_status)
-
- def __repr__(self):
- return '<JabberResource %s>' % self.jid.as_unicode()
-
-
- def send_file(self, filepath = None):
- if filepath is None:
- Hub = Hub
- import hub
- filepath = Hub.getInstance().get_file('Sending file to %s' % self.name)
-
- if filepath:
- self.protocol.send_file(self, fileinfo(filepath))
-
-
- send_file = action()(send_file)
-
-